package com.cndw.kungfu.model;

import java.io.Serializable;

import com.cndw.kungfu.core.CacheDataBase;
import com.cndw.kungfu.core.CacheDataKey;
import com.cndw.kungfu.model.pvp.ChallengeData;

/**
 * 武林大会数据对象
 * @author fantadust [9677889@qq.com]
 * @date 2012-8-18 下午2:05:07
 */
public class PvpChallengeSerialize extends CacheDataBase implements Serializable {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static PvpChallengeSerialize instance = null;
	
	private ChallengeData challengeData;

	private PvpChallengeSerialize() {
	}

	@Override
	public String getKey() {
		return CacheDataKey.keyPvpChallengeSerialize;
	}

	public static PvpChallengeSerialize getInstance() {
		if (instance == null) {
			synchronized (PvpChallengeSerialize.class) {
				if (instance == null) {
					CacheDataBase cacheData = Context.getSysServer().initCacheData(CacheDataKey.keyPvpChallengeSerialize);
					if (cacheData != null && cacheData instanceof PvpChallengeSerialize) {
						instance = (PvpChallengeSerialize) cacheData;
					}
					if (instance == null) {
						instance = new PvpChallengeSerialize();
					}
					if (instance.getSyncDBTime() == 0) {
						instance.commitSync();
					}
				}
			}

		}
		return instance;

	}
	/**
	 * 设置包里可以访问 因为转移数据
	 * @return
	 */
	protected ChallengeData getChallengeData() {
		if (challengeData == null) {
			synchronized (PvpChallengeSerialize.class) {
				if (challengeData == null) {
					challengeData = new ChallengeData();
				}
			}
		}
		challengeData.checkOrderMap();
		
		return challengeData;
	}
	
	protected void setChallengeData(ChallengeData challengeData) {
		if (challengeData == null) {
			return ;
		}
		this.challengeData = challengeData;
	}
	
	

}
